$(function() {
	var us_email = document.getElementById("us_email");
	var us_phone = document.getElementById("us_phone");
	var us_name = document.getElementById("us_name");
	var us_sex = document.getElementById("us_sex");
	var us_money = document.getElementById("us_money");
	var us_idcard = document.getElementById("us_idcard");
	var us_address = document.getElementById("us_address");
	$.ajax({
		url:base_path+"/user/user.do",
		type:"post",
		dataType:"json",
		success:function(user){
			us_email.value=user.us_email;
			us_phone.value=user.us_phone;
			us_name.value=user.us_name;
			us_sex.value=user.us_sex;
			us_money.value=user.us_money;
			us_idcard.value=user.us_idcard;
			us_address.value=user.us_address;
			
		}
		
		
	});
	$("#keep").click(keep);
});
function keep() {
	var us_email = $("#us_email").val().trim();
	var us_phone = $("#us_phone").val().trim();
	var us_name = $("#us_name").val().trim();
	var us_sex = $("#us_sex").val().trim();
	var us_idcard = $("#us_idcard").val().trim();
	var us_address = $("#us_address").val().trim();
	
	$("#email_span").html("");
	$("#phone_span").html("");
	$("#name_span").html("");
	$("#sex_span").html("");
	$("#idcard_span").html("");
	$("#address_span").html("");
	var ok=true;
	if(us_email==""){
		ok=false;
		$("#email_span").html("不能为空");
	}
	if(us_phone==""){
		ok=false;
		$("#phone_span").html("不能为空");
	}
	if(us_name==""){
		ok=false;
		$("#name_span").html("不能为空");
	}
	if(us_sex==""){
		ok=false;
		$("#sex_span").html("不能为空");
	}
	if(us_idcard==""){
		ok=false;
		$("#idcard_span").html("不能为空");
	}
	if(us_address==""){
		ok=false;
		$("#address_span").html("不能为空");
	}
	if(ok){
		$.ajax({
			url:base_path+"/user/update.do",
			type:"post",
			data:{"us_email":us_email,"us_phone":us_phone,"us_name":us_name,
				"us_sex":us_sex,"us_idcard":us_idcard,"us_address":us_address},
			dataType:"json",
			success:function(result){
			    if(result.status==0){
			    	alert(result.msg);
//			    	window.location.href ="login.html";
			    	window.location.href = "user_ps.html";
			    }
			}
				
		});
		
	}
}

